package dimensional.traveler.client.screens.battlefield;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.widget.core.client.ContentPanel;

import dimensional.traveler.client.mvc.ControlledComposite;
import dimensional.traveler.client.mvc.MediatedController;
import dimensional.traveler.client.resources.images.icons.Icons;
import dimensional.traveler.shared.model.missionSequence.Battle;

public class Battlefield extends ControlledComposite {

	private static BattlefieldUiBinder uiBinder = GWT.create(BattlefieldUiBinder.class);

	interface BattlefieldUiBinder extends UiBinder<Widget, Battlefield> {
	}

	@UiField
	ContentPanel centerContainer;

	private BattlefieldController controller = new BattlefieldController();

	public Battlefield(Battle nextMissionSequence) {
		initWidget(uiBinder.createAndBindUi(this));
		createGrid();
	}

	private void createGrid() {
		Grid grid = new Grid(4, 4);

		// Add images to the grid
		int numRows = grid.getRowCount();
		int numColumns = grid.getColumnCount();
		for (int row = 0; row < numRows; row++) {
			for (int col = 0; col < numColumns; col++) {
				grid.setWidget(row, col, new Image(Icons.INSTANCE.genericIcon()));
			}
		}

		centerContainer.setWidget(grid);
	}

	@Override
	public MediatedController getController() {
		return controller;
	}

}
